print('Calculate 1! + 2! + ... + n!:')

n = int(input('input n: '))

factorials_sum = 0
val = 1

for i in range(1, n+1):
    val *= i
    factorials_sum += val

print('The sum is: ', factorials_sum)
